//
//  ViewController.m
//  CLGLocationApp
//
//  Created by Liu Guocheng on 2018/4/3.
//  Copyright © 2018年 Sumavision. All rights reserved.
//

#import "ViewController.h"
#import "CLGLocationManager.h"

@interface ViewController () <CLGLocationManagerDelegate>
@property (weak, nonatomic) IBOutlet UITextView *locationTextView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[CLGLocationManager sharedManager] setDelegate:(id<CLGLocationManagerDelegate>)self];
    
    [[CLGLocationManager sharedManager] startMonitoring];
    
    
    
}

- (void)didGetLocationPlacemark:(CLPlacemark *)placemark error:(NSError *)error
{
    NSLog(@"placemark addressDictionary %@, %@", placemark.addressDictionary, error);
    
    NSString *placeName = [NSString stringWithFormat:@"name:%@\n country:%@\n location:%@\n region:%@\n thoroughfare:%@\n subThoroughfare:%@\n locality:%@\n subLocality:%@\n postalCode:%@", placemark.name, placemark.country, placemark.location, placemark.region, placemark.thoroughfare, placemark.subThoroughfare, placemark.locality, placemark.subLocality, placemark.postalCode];
    
    _locationTextView.text = placeName;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)navigateAction:(UIButton *)sender {
    [[CLGLocationManager sharedManager] externalNavigateToDestination:CLLocationCoordinate2DMake(40.0606470000, 116.4155530000) name:@"一个地方"];
}

@end
